home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / var / db / pkg / sys-devel / libperl-5.8.7 / libperl-5.8.7.ebuild < prev    next >
Encoding:
Text File  |  2006-04-25  |  10.7 KB  |  371 lines

  1. # Copyright 1999-2006 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # $Header: /var/cvsroot/gentoo-x86/sys-devel/libperl/libperl-5.8.7.ebuild,v 1.24 2006/01/15 10:23:07 tove Exp $
  4.  
  5. # The basic theory based on comments from Daniel Robbins <drobbins@gentoo.org>.
  6. #
  7. # We split the perl ebuild into libperl and perl.  The layout is as follows:
  8. #
  9. # libperl:
  10. #
  11. #  This is a slotted (SLOT=[0-9]*) ebuild, meaning we should be able to have a
  12. #  few versions that are not binary compadible installed.
  13. #
  14. #  How we get libperl.so multi-versioned, is by adding to the link command:
  15. #
  16. #    -Wl,-soname -Wl,libperl.so.`echo $(LIBPERL) | cut -d. -f3`
  17. #
  18. #  This gives us:
  19. #
  20. #    $(LIBPERL): $& perl$(OBJ_EXT) $(obj) $(LIBPERLEXPORT)
  21. #        $(LD) -o $@ $(SHRPLDFLAGS) perl$(OBJ_EXT) $(obj) \
  22. #              -Wl,-soname -Wl,libperl.so.`echo $(LIBPERL) | cut -d. -f3`
  23. #
  24. #  We then configure perl with LIBPERL set to:
  25. #
  26. #    LIBPERL="libperl.so.${SLOT}.`echo ${PV} | cut -d. -f1,2`"
  27. #
  28. #  Or with the variables defined in this ebuild:
  29. #
  30. #    LIBPERL="libperl.so.${PERLSLOT}.${SHORT_PV}"
  31. #
  32. #  The result is that our 'soname' is 'libperl.so.${PERLSLOT}' (at the time of
  33. #  writing this for perl-5.8.0, 'libperl.so.1'), causing all apps that is linked
  34. #  to libperl to link to 'libperl.so.${PERLSLOT}'.
  35. #
  36. #  If a new perl version, perl-z.y.z comes out that have a libperl not binary
  37. #  compatible with the previous version, we just keep the previous libperl
  38. #  installed, and all apps linked to it will still be able to use:
  39. #
  40. #    libperl.so.${PERLSLOT}'
  41. #
  42. #  while the new ones will link to:
  43. #
  44. #    libperl.so.$((PERLSLOT+1))'
  45. #
  46. # perl:
  47. #
  48. #  Not much to this one.  It compiles with a static libperl.a, and are unslotted
  49. #  (meaning SLOT=0).  We thus always have the latest *stable* perl version
  50. #  installed, with corrisponding version of libperl.  The perl ebuild will of
  51. #  course DEPEND on libperl.
  52. #
  53. # Martin Schlemmer <azarah@gentoo.org> (28 Dec 2002).
  54.  
  55. IUSE="berkdb debug gdbm ithreads"
  56.  
  57. inherit eutils flag-o-matic toolchain-funcs multilib
  58.  
  59. # The slot of this binary compat version of libperl.so
  60. PERLSLOT="1"
  61.  
  62. SHORT_PV="${PV%.*}"
  63. MY_P="perl-${PV/_rc/-RC}"
  64. S="${WORKDIR}/${MY_P}"
  65. DESCRIPTION="Larry Wall's Practical Extraction and Reporting Language"
  66. SRC_URI="ftp://ftp.cpan.org/pub/CPAN/src/${MY_P}.tar.bz2"
  67. HOMEPAGE="http://www.perl.org"
  68. SLOT="${PERLSLOT}"
  69. LIBPERL="libperl$(get_libname ${PERLSLOT}.${SHORT_PV})"
  70. LICENSE="Artistic GPL-2"
  71. KEYWORDS="alpha amd64 arm hppa ia64 m68k mips ppc ~ppc-macos ppc64 s390 sh sparc x86"
  72.  
  73. # rac 2004.08.06
  74.  
  75. # i am not kidding here. you will forkbomb yourself out of existence
  76. # because make check -n wants to make miniperl, which runs itself at
  77. # the very end to make sure it's working right. this behaves very
  78. # badly when you -n it, because it won't exist and will therefore try
  79. # to build itself again ad infinitum.
  80.  
  81. RESTRICT="test"
  82.  
  83. DEPEND="!elibc_uclibc? ( sys-apps/groff )
  84.     berkdb? ( sys-libs/db )
  85.     gdbm? ( >=sys-libs/gdbm-1.8.0 )"
  86.  
  87. RDEPEND="
  88.     berkdb? ( sys-libs/db )
  89.     gdbm? ( >=sys-libs/gdbm-1.8.0 )"
  90.  
  91. PDEPEND=">=dev-lang/perl-${PV}"
  92.  
  93. pkg_setup() {
  94.     # I think this should rather be displayed if you *have* 'ithreads'
  95.     # in USE if it could break things ...
  96.     if use ithreads
  97.     then
  98.         ewarn ""
  99.         ewarn "PLEASE NOTE: You are compiling perl-5.8 with"
  100.         ewarn "interpreter-level threading enabled."
  101.         ewarn "Threading is not supported by all applications "
  102.         ewarn "that compile against perl. You use threading at "
  103.         ewarn "your own discretion. "
  104.         ewarn ""
  105.         epause 10
  106.     else
  107.         ewarn ""
  108.         ewarn "PLEASE NOTE: If you want to compile perl-5.8 with"
  109.         ewarn "threading enabled , you must restart this emerge"
  110.         ewarn "with USE=ithreads emerge...."
  111.         ewarn "Threading is not supported by all applications "
  112.         ewarn "that compile against perl. You use threading at "
  113.         ewarn "your own discretion. "
  114.         ewarn ""
  115.         epause 10
  116.     fi
  117. }
  118.  
  119. src_unpack() {
  120.  
  121.     unpack ${A}
  122.  
  123.     # Fix the build scripts to create libperl with a soname of ${SLOT}.
  124.     # We basically add:
  125.     #
  126.     #   -Wl,-soname -Wl,libperl.so.`echo $(LIBPERL) | cut -d. -f3`
  127.     #
  128.     # to the line that links libperl.so, and then set LIBPERL to:
  129.     #
  130.     #   LIBPERL=libperl.so.${SLOT}.`echo ${PV} | cut -d. -f1,2`
  131.     #
  132.     cd ${S};
  133.     use userland_Darwin || epatch ${FILESDIR}/${PN}-create-libperl-soname.patch
  134.  
  135.     # uclibc support - dragonheart 2004.06.16
  136.     # Now upstreamed - MPC 2005.06.28
  137.     #cd ${S}; epatch ${FILESDIR}/${PN}-uclibc.patch
  138.  
  139.     # Configure makes an unwarranted assumption that /bin/ksh is a
  140.     # good shell. This patch makes it revert to using /bin/sh unless
  141.     # /bin/ksh really is executable. Should fix bug 42665.
  142.     # rac 2004.06.09
  143.     cd ${S}; epatch ${FILESDIR}/${PN}-noksh.patch
  144.  
  145.     # we need the same @INC-inversion magic here we do in perl
  146.     cd ${S}; epatch ${FILESDIR}/${PN}-reorder-INC.patch
  147. }
  148.  
  149. src_compile() {
  150.     # Perl has problems compiling with -Os in your flags
  151.     use elibc_uclibc || replace-flags "-Os" "-O2"
  152.     # This flag makes compiling crash in interesting ways
  153.     filter-flags "-malign-double"
  154.  
  155.     export LC_ALL="C"
  156.     local myconf=""
  157.  
  158.     case ${CHOST} in
  159.         *-freebsd*) osname="freebsd" ;;
  160.         *-netbsd*) osname="netbsd" ;;
  161.         *-openbsd*) osname="openbsd" ;;
  162.         *-darwin*) osname="darwin" ;;
  163.  
  164.         *) osname="linux" ;;
  165.     esac
  166.  
  167.     if use ithreads
  168.     then
  169.         einfo "using ithreads"
  170.         mythreading="-multi"
  171.         myconf="-Dusethreads ${myconf}"
  172.         myarch=$(get_abi_CHOST)
  173.         myarch="${myarch%%-*}-${osname}-thread"
  174.     else
  175.         myarch=$(get_abi_CHOST)
  176.         myarch="${myarch%%-*}-${osname}"
  177.     fi
  178.  
  179.     ewarn "myarch: ${myarch}"
  180.  
  181.     if use gdbm
  182.     then
  183.         myconf="${myconf} -Di_gdbm"
  184.     fi
  185.     if use berkdb
  186.     then
  187.         myconf="${myconf} -Di_db -Di_ndbm"
  188.     else
  189.         myconf="${myconf} -Ui_db -Ui_ndbm"
  190.     fi
  191.     if use mips
  192.     then
  193.         # this is needed because gcc 3.3-compiled kernels will hang
  194.         # the machine trying to run this test - check with `Kumba
  195.         # <rac@gentoo.org> 2003.06.26
  196.         myconf="${myconf} -Dd_u32align"
  197.     fi
  198.  
  199.     if use debug
  200.     then
  201.         CFLAGS="${CFLAGS} -g"
  202.     fi
  203.  
  204.     if use sparc
  205.     then
  206.         myconf="${myconf} -Ud_longdbl"
  207.     fi
  208.  
  209.     rm -f config.sh Policy.sh
  210.  
  211.     [ -n "${ABI}" ] && myconf="${myconf} -Dusrinc=$(get_ml_incdir)"
  212.  
  213.     [[ ${ELIBC} == "FreeBSD" ]] && myconf="${myconf} -Dlibc=/usr/lib/libc.a"
  214.  
  215.     if [[ $(get_libdir) != "lib" ]] ; then
  216.         myconf="${myconf} -Dlibpth='/usr/local/$(get_libdir) /$(get_libdir) \
  217.         /usr/$(get_libdir)'"
  218.     fi
  219.  
  220.     sh Configure -des \
  221.         -Darchname="${myarch}" \
  222.         -Dcccdlflags='-fPIC' \
  223.         -Dccdlflags='-rdynamic' \
  224.         -Dcc="$(tc-getCC)" \
  225.         -Dprefix='/usr' \
  226.         -Dvendorprefix='/usr' \
  227.         -Dsiteprefix='/usr' \
  228.         -Dlocincpth=' ' \
  229.         -Doptimize="${CFLAGS}" \
  230.         -Duselargefiles \
  231.         -Duseshrplib \
  232.         -Dman3ext='3pm' \
  233.         -Dlibperl="${LIBPERL}" \
  234.         -Dd_dosuid \
  235.         -Dd_semctl_semun \
  236.         -Dcf_by='Gentoo' \
  237.         -Ud_csh \
  238.         ${myconf} || die
  239.  
  240.     emake -j1 -f Makefile depend || die "Couldn't make libperl$(get_libname) depends"
  241.     emake -j1 -f Makefile LIBPERL=${LIBPERL} ${LIBPERL} || die "Unable to make libperl$(get_libname)"
  242.     mv ${LIBPERL} ${WORKDIR}
  243. }
  244.  
  245. src_install() {
  246.  
  247.     export LC_ALL="C"
  248.  
  249.     if [ "${PN}" = "libperl" ]
  250.     then
  251.         dolib.so ${WORKDIR}/${LIBPERL}
  252.         dosym ${LIBPERL} /usr/$(get_libdir)/libperl$(get_libname ${PERLSLOT})
  253.     else
  254.         # Need to do this, else apps do not link to dynamic version of
  255.         # the library ...
  256.         local coredir="/usr/lib/perl5/${PV}/${myarch}${mythreading}/CORE"
  257.         dodir ${coredir}
  258.         dosym ../../../../../$(get_libdir)/${LIBPERL} ${coredir}/${LIBPERL}
  259.         dosym ../../../../../$(get_libdir)/${LIBPERL} ${coredir}/libperl$(get_libname ${PERLSLOT})
  260.         dosym ../../../../../$(get_libdir)/${LIBPERL} ${coredir}/libperl$(get_libname)
  261.  
  262.         # Fix for "stupid" modules and programs
  263.         dodir /usr/lib/perl5/site_perl/${PV}/${myarch}${mythreading}
  264.  
  265.         make DESTDIR="${D}" \
  266.             INSTALLMAN1DIR="${D}/usr/share/man/man1" \
  267.             INSTALLMAN3DIR="${D}/usr/share/man/man3" \
  268.             install || die "Unable to make install"
  269.  
  270.         cp -f utils/h2ph utils/h2ph_patched
  271.  
  272.         LD_LIBRARY_PATH=. ./perl -Ilib utils/h2ph_patched \
  273.             -a -d ${D}/usr/lib/perl5/${PV}/${myarch}${mythreading} <<EOF
  274. asm/termios.h
  275. syscall.h
  276. syslimits.h
  277. syslog.h
  278. sys/ioctl.h
  279. sys/socket.h
  280. sys/time.h
  281. wait.h
  282. EOF
  283.  
  284.         # This is to fix a missing c flag for backwards compat
  285.         for i in `find ${D}/usr/lib/perl5 -iname "Config.pm"`;do
  286.             sed -e "s:ccflags=':ccflags='-DPERL5 :" \
  287.                 -e "s:cppflags=':cppflags='-DPERL5 :" \
  288.                 ${i} > ${i}.new &&\
  289.                 mv ${i}.new ${i} || die "Sed failed"
  290.         done
  291.  
  292.         # A poor fix for the miniperl issues
  293.         dosed 's:./miniperl:/usr/bin/perl:' /usr/lib/perl5/${PV}/ExtUtils/xsubpp
  294.         fperms 0444 /usr/lib/perl5/${PV}/ExtUtils/xsubpp
  295.         dosed 's:./miniperl:/usr/bin/perl:' /usr/bin/xsubpp
  296.         fperms 0755 /usr/bin/xsubpp
  297.  
  298.         ./perl installman \
  299.             --man1dir="${D}/usr/share/man/man1" --man1ext='1' \
  300.             --man3dir="${D}/usr/share/man/man3" --man3ext='3'
  301.  
  302.         # This removes ${D} from Config.pm and .packlist
  303.         for i in `find ${D} -iname "Config.pm"` `find ${D} -iname ".packlist"`;do
  304.             einfo "Removing ${D} from ${i}..."
  305.             sed -e "s:${D}::" ${i} > ${i}.new &&\
  306.                 mv ${i}.new ${i} || die "Sed failed"
  307.         done
  308.     fi
  309.  
  310.     dodoc Changes* Artistic Copying README Todo* AUTHORS
  311.  
  312.     if [ "${PN}" = "perl" ]
  313.     then
  314.         # HTML Documentation
  315.         # We expect errors, warnings, and such with the following.
  316.  
  317.         dodir /usr/share/doc/${PF}/html
  318.         ./perl installhtml \
  319.             --podroot='.' \
  320.             --podpath='lib:ext:pod:vms' \
  321.             --recurse \
  322.             --htmldir="${D}/usr/share/doc/${PF}/html" \
  323.             --libpods='perlfunc:perlguts:perlvar:perlrun:perlop'
  324.     fi
  325. }
  326.  
  327. pkg_postinst() {
  328.  
  329.     # Make sure we do not have stale/invalid libperl.so 's ...
  330.     if [ -f "${ROOT}usr/$(get_libdir)/libperl$(get_libname)" -a ! -L "${ROOT}usr/$(get_libdir)/libperl$(get_libname)" ]
  331.     then
  332.         mv -f ${ROOT}usr/$(get_libdir)/libperl$(get_libname) ${ROOT}usr/$(get_libdir)/libperl$(get_libname).old
  333.     fi
  334.  
  335.     # Next bit is to try and setup the /usr/lib/libperl.so symlink
  336.     # properly ...
  337.     local libnumber="`ls -1 ${ROOT}usr/$(get_libdir)/libperl$(get_libname ?.*) | grep -v '\.old' | wc -l`"
  338.     if [ "${libnumber}" -eq 1 ]
  339.     then
  340.         # Only this version of libperl is installed, so just link libperl.so
  341.         # to the *soname* version of it ...
  342.         ln -snf libperl$(get_libname ${PERLSLOT}) ${ROOT}usr/$(get_libdir)/libperl$(get_libname)
  343.     else
  344.         if [ -x "${ROOT}/usr/bin/perl" ]
  345.         then
  346.             # OK, we have more than one version .. first try to figure out
  347.             # if there are already a perl installed, if so, link libperl.so
  348.             # to that *soname* version of libperl.so ...
  349.             local perlversion="`${ROOT}/usr/bin/perl -V:version | cut -d\' -f2 | cut -d. -f1,2`"
  350.  
  351.             cd ${ROOT}usr/$(get_libdir)
  352.             # Link libperl.so to the *soname* versioned lib ...
  353.             ln -snf `echo libperl$(get_libname ?.${perlversion}) | cut -d.  -f1,2,3` libperl$(get_libname)
  354.         else
  355.             local x latest
  356.  
  357.             # Nope, we are not so lucky ... try to figure out what version
  358.             # is the latest, and keep fingers crossed ...
  359.             for x in `ls -1 ${ROOT}usr/$(get_libdir)/libperl$(get_libname ?.*)`
  360.             do
  361.                 latest="${x}"
  362.             done
  363.  
  364.             cd ${ROOT}usr/$(get_libdir)
  365.             # Link libperl.so to the *soname* versioned lib ...
  366.             ln -snf `echo ${latest##*/} | cut -d. -f1,2,3` libperl$(get_libname)
  367.         fi
  368.     fi
  369. }
  370.  
  371.